

--x_axis = 1
--y_axis = 2
--z_axis = 3
SetSFXOccupy = setSFXoccupy		--standard case for function names

-- Explosion generators
UNIT_SFX1 = 1024

-- Weapons
FIRE_W1 = 2048

DETO_W1 = 4096

local spGetUnitHealth = Spring.GetUnitHealth

local smokePiece = {}

function SmokeUnit()
	if not (smokePiece and smokePiece[1]) then return end
	local health,maxHealth,_,_,buildPercent = spGetUnitHealth(unitID)
	while buildPercent < 100 do Sleep(400) end
	--Smoke loop
	while true do
		--How is the unit doing?
		local health, maxHealth = spGetUnitHealth(unitID)
		local healthPercent = health/maxHealth --GetUnitValue(COB.HEALTH)

		if (healthPercent < .66) then -- only smoke if less then 2/3rd health left
			EmitSfx(smokePiece[random(1,#smokePiece)], SMOKEPUFF)
		end
		Sleep(100*healthPercent + random(100,200))
	end
end
